package com.xuyh.logonline.properties;

import lombok.Data;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.util.StringUtils;

import javax.annotation.PostConstruct;

@Data
@Configuration
@ConfigurationProperties(prefix = LogOnlineProperties.PREFIX)
public class LogOnlineProperties implements InitializingBean {

    public final static String PREFIX = "logOnline";

    /**
     * 应用对外的请求的地址
     * <p>
     * 例如：项目的端口为:8080,项目前缀为:admin(也可以没有),对外开放的ip为：192.168.1.2;
     * <p>
     * 则url为: 192.168.1.2:8080/admin
     */
    private String url;

    /**
     * 显示的等级
     * info,debug,warn,error
     */
    private String[] level;

    private String[] className;

    @Override
    public void afterPropertiesSet() throws Exception {
        if (StringUtils.isEmpty(url)) {
            throw new NullPointerException("未配置在线日志的对外路径！");
        }
    }
}
